package com.thoughtworks.biblioteca;

import java.util.LinkedList;
import java.util.List;

//Understands a set of books that are available for checkout
class BooksCatalog {
	private List<Book> bookCatalog = new LinkedList<Book>();
	public static final boolean CHECKOUT_SUCCESSFUL = true;
	public static final boolean CHECKOUT_FAILED = false;

	public BooksCatalog() {
		bookCatalog.add(new Book(1,"Sweet Valley High vol. 4", "John Travolta"));
		bookCatalog.add(new Book(2,"eXtreme Programming Explained", "Kent Beck"));
		bookCatalog.add(new Book(3,"How to Win Friends and Influence People",
				"Dale Carnagie"));
		bookCatalog.add(new Book(4,"How to Cheat at TWU Assignements",
				"Anonymous"));

	}

	public boolean checkoutBook(int bookNumber) {
		for(Book book:bookCatalog){
			if (book.checkAvailability(bookNumber)){
				return CHECKOUT_SUCCESSFUL;
			}
		}
		return CHECKOUT_FAILED;

	}

	public List<Book> getBookCatalog() {
		return bookCatalog;
	}

}
